home *** CD-ROM | disk | FTP | other *** search
/ Stockbyte 104: Worth Celebrating / Stockbyte - Worth Celebrating - Disc 1.iso / mac / Mac Browser / Portfolio Help / webhelp3.js < prev    next >
Text File  |  2000-04-26  |  48KB  |  1,707 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // RoboHELP« WebHelp 3 Dynamic HTML Effects Script
  3. // Copyright ⌐ 1998-1999 Blue Sky Software Corporation.  All rights reserved.
  4.  
  5. // Version= 1.01
  6.  
  7. // Warning:  Do not modify this file.  It is generated by RoboHELP« and changes will be overwritten.
  8.  
  9. //{{WH3_SYMBOL_SECTION
  10. var gstrNavFrmst = "navpane1.htm";
  11. var gstrTocDhtml = "tocdhtml.htm";
  12. var gstrIdxDhtml = "idxdhtml.htm";
  13. var gstrFtsDhtml = "ftsdhtml.htm";
  14. var gstrIniDhtml = "tocdhtml.htm";
  15. //}}WH3_SYMBOL_SECTION
  16.  
  17. var gnPageWidth = 0;
  18. var gnPageHeight = 0;
  19. var gstrColl = "";
  20. var gstrStyle = ""
  21. var gbNav4 = false;
  22. var gbIE4 = false;
  23. var gbIE = false;
  24. var gbIE5 = false;
  25. var gbTocLoaded = false;
  26. var gbIndexLoaded = false;
  27. var gbFtsLoaded = false;
  28. var gAgent = navigator.userAgent.toLowerCase(); 
  29. var gbMac = (gAgent.indexOf("mac") != -1);
  30.  
  31. var gbIndexInputEnable = false;
  32. var gIndexTopicArray = new Array();
  33. var gIndexKeywordArray = new Array();
  34. var gIndexLetterArray = new Array();
  35.  
  36. var gbFtsInputEnable = false;
  37. var gFtsKeywordArray = new Array();
  38. var gFtsTopicArray = new Array();
  39. var gFtsStopArray = new Array();
  40.  
  41. gbIE = (navigator.appName.indexOf("Microsoft") != -1);
  42. if (parseInt(navigator.appVersion) >= 4) {
  43.     gbNav4 = (navigator.appName == "Netscape");
  44.     gbIE4 = (navigator.appName.indexOf("Microsoft") != -1);
  45. }
  46. if (gbNav4) {
  47.     document.gnPageWidth = innerWidth;
  48.     document.gnPageHeight = innerHeight;
  49. //    document.captureEvents(Event.RESIZE);
  50. //    document.onresize = HandleResize;
  51. } else if (gbIE4) {
  52.     gstrStyle = ".style";
  53.     gstrColl = "all.";
  54.     if (gAgent.indexOf("msie 5.0") != -1) {
  55.         gbIE5 = true;
  56.     }
  57. }
  58.  
  59. function HandleResize()
  60. {
  61. //alert('handle resize: ' + window.document.location.href);
  62.     if (innerWidth != window.document.gnPageWidth || innerHeight != window.document.gnPageHeight) {
  63.         if (window.document.gnPageWidth == 0) {
  64.             window.document.gnPageWidth = innerWidth;
  65.             window.document.gnPageHeight = innerHeight;
  66.         } else {
  67.             window.document.gnPageWidth = innerWidth;
  68.             window.document.gnPageHeight = innerHeight;
  69.             window.document.location.reload();
  70.         }
  71.         return false;
  72.     }
  73. }
  74.  
  75.  
  76. function FindTopLevelLayer(strID)
  77. {
  78.     if (gbNav4) {
  79.         return FindTopLevelLayerNS(strID);
  80.     } else if (gbIE4) {
  81.         var obj = eval("document.all." + strID);
  82.         return obj;
  83.     }
  84.     return null;
  85. }
  86.  
  87. function FindTopLevelLayerNS(strID)
  88. {
  89.     for (var iLayer = 0; iLayer < window.document.layers.length; iLayer++) {
  90.         if (window.document.layers[iLayer].id == strID) {
  91.             return window.document.layers[iLayer];
  92.         }
  93.     }
  94.  
  95.     // This section is added to the search because when the scrollbar is
  96.     // added, Netscape messes up the layer list. This is another way
  97.     // of getting to the layers
  98.     if (window.document.layers.length > 0) {
  99.         var iLayer = 0;
  100.         var objLayer = window.document.layers[0];
  101.         while ((iLayer < 20) && (objLayer != null)) {
  102.             if (objLayer.id == strID) {
  103.                 return objLayer;
  104.             }
  105.             iLayer++;
  106.             objLayer = objLayer.above;
  107.         }
  108.     }
  109.     return null;
  110. }
  111.  
  112. function GetAttribObject(obj)
  113. {
  114.     var objAttrib = null;
  115.     if (typeof obj == "string") {
  116.         objAttrib = eval("document." + gstrColl + obj + gstrStyle);
  117.     } else {
  118.         objAttrib = obj;
  119.     }
  120.     return objAttrib;
  121. }
  122.  
  123.  
  124. function TabFrame()
  125. {
  126.     if (gbNav4) {
  127.         return Tabs;
  128.     } else {
  129.         return document.frames['Tabs'];
  130.     }
  131. }
  132.  
  133. function NavFrame()
  134. {
  135.     if (gbNav4) {
  136.         return Navigation;
  137.     } else {
  138.         return document.frames['Navigation'];
  139.     }
  140. }
  141.  
  142. function ShowDiv(strDiv, bShow)
  143. {
  144.     var Div = FindTopLevelLayer(strDiv);
  145.     if (Div == null) {
  146.         return;
  147.     }
  148.  
  149.     if (gbNav4) {
  150.         if (bShow == true) {
  151.             Div.visibility = 'show';
  152. //            Div.left = 0;
  153.             Div.moveToAbsolute(0, 0);
  154.         } else {
  155.             Div.visibility = 'hide';
  156. //            Div.left = -2000;
  157.             Div.moveToAbsolute(-2000, 0);
  158.         }
  159.     } else {
  160.         Div.style.visibility = (bShow == true) ? 'visible' : 'hidden';
  161.     }
  162.     return;
  163. }
  164.  
  165. function LoadTocContent(TocDiv)
  166. {
  167.     var strFile = location.href;
  168.     var nPosFile = strFile.indexOf(gstrNavFrmst);
  169.     strFile = strFile.substring(0, nPosFile);
  170.     strFile += gstrTocDhtml;
  171.     if (gbNav4) {
  172.         TocDiv.src = strFile;
  173.     } else if (gbIE4) {
  174. //        TocDiv.document.frames['TocIFrame'].location.href = strFile;
  175. //alert('loading: ' + strFile + ' into: ' + TocDiv.document.all.TocIFrame);
  176.         TocDiv.document.all.TocIFrame.src = strFile;
  177.     }
  178.     gbTocLoaded = true;
  179.     return;
  180. }
  181.  
  182. function LoadIndexContent(IndexDiv)
  183. {
  184.     var strFile = location.href;
  185.     var nPosFile = strFile.indexOf(gstrNavFrmst);
  186.     strFile = strFile.substring(0, nPosFile);
  187.     strFile += gstrIdxDhtml;
  188.     if (gbNav4) {
  189.         IndexDiv.src = strFile;
  190.     } else if (gbIE4) {
  191. //        IndexDiv.document.frames['IndexIFrame'].location.href = strFile;
  192.         IndexDiv.document.all.IndexIFrame.src = strFile;
  193.     }
  194.     gbIndexLoaded = true;
  195.     return;
  196. }
  197.  
  198. function LoadFtsContent(FtsDiv)
  199. {
  200.     var strFile = location.href;
  201.     var nPosFile = strFile.indexOf(gstrNavFrmst);
  202.     strFile = strFile.substring(0, nPosFile);
  203.     strFile += gstrFtsDhtml;
  204.     if (gbNav4) {
  205.         FtsDiv.src = strFile;
  206.     } else if (gbIE4) {
  207. //        FtsDiv.document.frames['FtsIFrame'].location.href = strFile;
  208.         FtsDiv.document.all.FtsIFrame.src = strFile;
  209.     }
  210.     gbFtsLoaded = true;
  211.     return;
  212. }
  213.  
  214.  
  215. function TimeoutChangeToTOC()
  216. {
  217.     if (!gbTocLoaded) {
  218.         var TocDiv = window.NavFrame().FindTopLevelLayer('TocNav');
  219.         if (TocDiv != null) {
  220.             LoadTocContent(TocDiv);
  221.         }
  222.     }
  223.     if (window.TabFrame().document.images['TocTab'] != null) {
  224.         window.TabFrame().document.images['TocTab'].src='bssctab1.gif';
  225.     }
  226.     if (window.TabFrame().document.images['IndexTab'] != null) {
  227.         window.TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  228.     }
  229.     if (window.TabFrame().document.images['FtsTab'] != null) {
  230.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  231.     }
  232.     window.NavFrame().ShowDiv('TocNav', true);
  233.     window.NavFrame().ShowDiv('IndexNav', false);
  234.     window.NavFrame().ShowDiv('FtsNav', false);
  235.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  236.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  237.     }
  238. }
  239.  
  240. function ChangeToTOC()
  241. {
  242.     setTimeout("TimeoutChangeToTOC();", 50);
  243.     return;
  244. }
  245.  
  246. function SelectTOC()
  247. {
  248.     if (!gbTocLoaded) {
  249.         var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  250.         if (TocDiv != null) {
  251.             LoadTocContent(TocDiv);
  252.         }
  253.     }
  254.     if (TabFrame().document.images['TocTab'] != null) {
  255.         TabFrame().document.images['TocTab'].src='bssctab1.gif';
  256.     }
  257.     if (TabFrame().document.images['IndexTab'] != null) {
  258.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  259.     }
  260.     if (TabFrame().document.images['FtsTab'] != null) {
  261.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  262.     }
  263.     NavFrame().ShowDiv('TocNav', true);
  264.     NavFrame().ShowDiv('IndexNav', false);
  265.     NavFrame().ShowDiv('FtsNav', false);
  266.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  267.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('TocNav'));
  268.     }
  269. }
  270.  
  271. function TimeoutChangeToIndex()
  272. {
  273.     if (!gbIndexLoaded) {
  274.         var IndexDiv = window.NavFrame().FindTopLevelLayer('IndexNav');
  275.         if (IndexDiv != null) {
  276.             LoadIndexContent(IndexDiv);
  277.         }
  278.     }
  279.     if (window.TabFrame().document.images['TocTab'] != null) {
  280.         window.TabFrame().document.images['TocTab'].src='bssctab2.gif';
  281.     }
  282.     if (window.TabFrame().document.images['IndexTab'] != null) {
  283.         window.TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  284.     }
  285.     if (window.TabFrame().document.images['FtsTab'] != null) {
  286.         window.TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  287.     }
  288.     window.NavFrame().ShowDiv('TocNav', false);
  289.     window.NavFrame().ShowDiv('IndexNav', true);
  290.     window.NavFrame().ShowDiv('FtsNav', false);
  291.     if (gbNav4 && window.NavFrame().window.NSscrollbar) {
  292.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav'));
  293.     }
  294. }
  295.  
  296.  
  297. function ChangeToIndex()
  298. {
  299.     setTimeout("TimeoutChangeToIndex();", 50);
  300. }
  301.  
  302. function SelectIndex()
  303. {
  304.     if (!gbIndexLoaded) {
  305.         var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  306.         if (IndexDiv != null) {
  307.             LoadIndexContent(IndexDiv);
  308.         }
  309.     }
  310.     if (TabFrame().document.images['TocTab'] != null) {
  311.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  312.     }
  313.     if (TabFrame().document.images['IndexTab'] != null) {
  314.         TabFrame().document.images['IndexTab'].src='bssctab3.gif';
  315.     }
  316.     if (TabFrame().document.images['FtsTab'] != null) {
  317.         TabFrame().document.images['FtsTab'].src='bssctab6.gif';
  318.     }
  319.     NavFrame().ShowDiv('TocNav', false);
  320.     NavFrame().ShowDiv('IndexNav', true);
  321.     NavFrame().ShowDiv('FtsNav', false);
  322.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  323.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('IndexNav') );
  324.     }
  325.  
  326.     setTimeout("IndexFocus()", 200);
  327. }
  328.  
  329.  
  330. function SelectFTS()
  331. {
  332.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  333.     if (!gbFtsLoaded) {
  334.         if (FtsDiv != null) {
  335.             LoadFtsContent(FtsDiv);
  336.         }
  337.     }
  338.     if (TabFrame().document.images['TocTab'] != null) {
  339.         TabFrame().document.images['TocTab'].src='bssctab2.gif';
  340.     }
  341.     if (TabFrame().document.images['IndexTab'] != null) {
  342.         TabFrame().document.images['IndexTab'].src='bssctab4.gif';
  343.     }
  344.     if (TabFrame().document.images['FtsTab'] != null) {
  345.         TabFrame().document.images['FtsTab'].src='bssctab5.gif';
  346.     }
  347.     NavFrame().ShowDiv('TocNav', false);
  348.     NavFrame().ShowDiv('IndexNav', false);
  349.     NavFrame().ShowDiv('FtsNav', true);
  350.     if (gbNav4 && NavFrame().window.NSscrollbar) {
  351.         NavFrame().window.NSscrollbar.SetActiveLayer(NavFrame().FindTopLevelLayer('FtsNav'));
  352.     }
  353.  
  354.     setTimeout("FTSFocus()", 200);
  355. }
  356.  
  357. function FTSFocus()
  358. {
  359.     var FtsDiv = NavFrame().FindTopLevelLayer('FtsNav');
  360.     if (gbIE4) {
  361.         FtsDiv = FtsDiv.document.frames['FtsIFrame'];
  362.     }
  363.  
  364.     if (FtsDiv.FtsInputForm != null) {
  365.         FtsDiv.FtsInputForm.ftsField.focus();
  366.     }
  367. }
  368.  
  369. function IndexFocus()
  370. {
  371.  
  372.     var IndexDiv = NavFrame().FindTopLevelLayer('IndexNav');
  373.     if (gbIE4) {
  374.         IndexDiv = IndexDiv.document.frames['IndexIFrame'];
  375.     }
  376.  
  377.     if (IndexDiv.IndexInputForm != null) {
  378.         IndexDiv.IndexInputForm.keywordField.focus();
  379.     }
  380. }
  381.  
  382. function SelectInitialTab()
  383. {
  384.     // Create the necessary IFrames for IE
  385.     if (gbIE4) {
  386.         if (FindTopLevelLayer('TocNav') != null) {
  387.             var nIFrameHeight = FindTopLevelLayer('TocNav').style.pixelHeight - 10;
  388.             var strIFrame = '<IFRAME ID="TocIFrame" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  389.             if (gbMac) {
  390.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  391.             } else {
  392.                 strIFrame += '100%;"></IFRAME>';
  393.             }
  394.             FindTopLevelLayer('TocNav').innerHTML = strIFrame;
  395.         }
  396.         if (FindTopLevelLayer('IndexNav') != null) {
  397.             var nIFrameHeight = FindTopLevelLayer('IndexNav').style.pixelHeight - 10;
  398.             var strIFrame = '<IFRAME ID="IndexIFrame" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  399.             if (gbMac) {
  400.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  401.             } else {
  402.                 strIFrame += '100%;"></IFRAME>';
  403.             }
  404.             FindTopLevelLayer('IndexNav').innerHTML = strIFrame;
  405.         }
  406.  
  407.         if (FindTopLevelLayer('FtsNav') != null) {
  408.             var nIFrameHeight = FindTopLevelLayer('FtsNav').style.pixelHeight - 10;
  409.             var strIFrame = '<IFRAME ID="FtsIFrame" BORDER=0 FRAMEBORDER=no STYLE="position:absolute; left:2%; width:92%; height:';
  410.             if (gbMac) {
  411.                 strIFrame += nIFrameHeight + 'px;"></IFRAME>';
  412.             } else {
  413.                 strIFrame += '100%;"></IFRAME>';
  414.             }
  415.             FindTopLevelLayer('FtsNav').innerHTML = strIFrame;
  416.         }
  417.     }
  418.  
  419.     // Call the real selection function
  420.     setTimeout("SelectInitTabReal()", 50);
  421. }
  422.  
  423. function SelectInitTabReal()
  424. {
  425.     parent.gbTocLoaded = false;
  426.     parent.gbIndexLoaded = false;
  427.     parent.gbFtsLoaded = false;
  428.  
  429.     if (gstrIniDhtml == gstrTocDhtml)    {
  430.         parent.SelectTOC();
  431.     } else if (gstrIniDhtml == gstrIdxDhtml) {
  432.         parent.SelectIndex();
  433.     } else if (gstrIniDhtml == gstrFtsDhtml) {
  434.         parent.SelectFTS();
  435.     }
  436.  
  437. //    if (FindTopLevelLayer('TocNav') != null) {
  438. //        parent.SelectTOC();
  439. //    } else if (FindTopLevelLayer('IndexNav') != null) {
  440. //        parent.SelectIndex();
  441. //    } else if (FindTopLevelLayer('FtsNav') != null) {
  442. //        parent.SelectFTS();
  443. //    }
  444. }
  445.  
  446.  
  447. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  448. //
  449. // Index code
  450. //
  451. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  452.  
  453. var gbIndexLayerInit = false;
  454. function IndexInitPage()
  455. {
  456.     parent.gbIndexLayerInit = false;
  457.     if (gbNav4) {
  458.         TocBuildLayerArrayNS();
  459.         onLoad = TocArrangeAllLayerNS();
  460.     } else if (gbIE4) {
  461.  
  462.         // Mark all Index blocks as "expanded"
  463.         var tempColl = document.all.tags("DIV");
  464.         for (var i = 0; i < tempColl.length; i++) {
  465.             if (tempColl(i).className == "child") tempColl(i).style.display = "block";
  466.         }
  467.  
  468.         // Make an array of parents so we can access them directly
  469.         var tempColl = document.all.tags("DIV");
  470.         var iLetterIndex = 0;
  471.         var nACharCode = "A".charCodeAt(0);
  472.         for (var i = 0; i < tempColl.length; i++) {
  473.             if (tempColl(i).className == "parent") {
  474.                 if (tempColl(i).innerText == "#") {
  475.                     gIndexLetterArray[0] = tempColl(i);
  476.                 } else {
  477.                     iLetterIndex = tempColl(i).innerText.charCodeAt(0);
  478.                     iLetterIndex -= nACharCode;
  479.                     iLetterIndex += 1;
  480.                     gIndexLetterArray[iLetterIndex] = tempColl(i);
  481.                 }
  482.             }
  483.         }
  484.     }
  485.     setTimeout("parent.gbIndexLayerInit = true;",1000);
  486.     return;
  487. }
  488.  
  489. function IndexWriteClassStyle()
  490. {
  491.     document.write("<STYLE TYPE='text/css'>");
  492.     if (gbNav4) {
  493.         document.write(".IndexItem {visibility:inherit; font-size:9pt;}");
  494.         document.write(".parent {font-size:10pt; position:absolute; visibility:hidden}");
  495.         document.write(".child {font-size:10pt; position:absolute; visibility:hidden}");
  496.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  497.         document.write("DIV {margin-left:10pt; margin-top:0pt; margin-bottom:0pt}");
  498.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  499.         document.write("A:link {text-decoration: none; color: 000000}");
  500.         document.write("A:visited {text-decoration: none; color: 333333}");
  501.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  502.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  503.     } else if (gbIE4) {
  504.         if (gbMac) {
  505.             document.write(".IndexItem {visibility:inherit; font-size:12pt;}");
  506.             document.write(".parent {font-size:14pt;}");
  507.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  508.             document.write("P {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  509.             document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  510.             if (!gbIE5) {
  511.                 document.write("H6.firstsub {font-family:'Arial'; color:#cccccc; font-size:12pt; margin-top:-10pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  512.             }
  513.         } else {
  514.             document.write(".IndexItem {visibility:inherit; font-size:8pt;}");
  515.             document.write(".parent {font-size:10pt;}");
  516.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  517.             document.write("P {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
  518.             document.write("H6 {font-family:'Arial'; color:#cccccc; font-size:9pt; margin-top:0pt; margin-bottom:0pt; font-style:normal;font-weight:normal;}");
  519.         }
  520.         document.write(".child {display:block}");
  521.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  522.         document.write("A:link {text-decoration: none; color: 000000}");
  523.         document.write("A:visited {text-decoration: none; color: 333333}");
  524.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  525.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  526.     }
  527.     document.write("</STYLE>");
  528.     return;
  529. }
  530.  
  531. //Define variable arguments as: strTitle, strUrl
  532. function TopicEntry() 
  533. {
  534.     var argLen = TopicEntry.arguments.length;
  535.     this.strTitle = TopicEntry.arguments[0];
  536.     this.strURL = TopicEntry.arguments[1];
  537. //    alert("Title: " + this.strTitle + "  URL: " + this.strURL);
  538. }
  539.  
  540. //Define variable arguments as: strKeyword [,strTopicIndex]*
  541. function IndexKeywordEntry() 
  542. {
  543.     var argLen = IndexKeywordEntry.arguments.length;
  544.     this.strKeyword = IndexKeywordEntry.arguments[0];
  545.     this.arrayTopics = new Array();
  546.  
  547.     // Now add all of the topic entries
  548.     for (var i=0; i < argLen - 1; i++) {
  549.         this.arrayTopics[i] = IndexKeywordEntry.arguments[i + 1];
  550.     }
  551. }
  552.  
  553.  
  554. function IndexBody()
  555. {
  556.     // Get the appropriate item to add items to
  557.     var layerFind = null;
  558.     if (gbIE4) {
  559.         layerFind = parent.document.frames['idxbody'];
  560.     } else if (gbNav4) {
  561.         layerFind = parent.document.idxbody.document;
  562.     }
  563.     
  564.     return layerFind;
  565. }
  566.  
  567. function IndexForm()
  568. {
  569.     // Get the appropriate item to add items to
  570.     var layerFind = null;
  571.     if (gbIE4) {
  572.         layerFind = parent.document.frames['idxform'];
  573.     } else if (gbNav4) {
  574.         layerFind = parent.document.idxform.document;
  575.     }
  576.     
  577.     return layerFind;
  578. }
  579.  
  580. function IndexExpandIt(elId, bForceOpen) 
  581. {
  582.     var layerChild = null;
  583.     if (gbIE4) {
  584.         layerChild = TocExpandIE(elId, false, bForceOpen);
  585.  
  586.         if (!bForceOpen) {
  587.             var nNewScroll = document.body.scrollTop;
  588.             if (layerChild.style.display == "block") {
  589.                 var nItemTop = layerChild.offsetTop;
  590.                 var nItemBottom = nItemTop + layerChild.offsetHeight;
  591.                 // Make sure the bottom is visible if possible
  592.                 if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  593.                     nNewScroll = nItemBottom - document.body.clientHeight;
  594.                 }
  595.                 // If expanded item is bigger than the client area, scroll the item to the top
  596.                 if (nItemBottom - nItemTop > document.body.clientHeight) {
  597.                     nNewScroll = nItemTop - 20;
  598.                 }
  599.             }
  600.             document.body.scrollTop = nNewScroll;
  601.         }
  602.     } else if (gbNav4) {
  603.         layerChild = TocExpandNS(elId, false, bForceOpen);
  604.         if (window.NSscrollbar != null) {
  605.             window.NSscrollbar.SetContentHeight(nextY);
  606.             window.NSscrollbar.SetContentWidth(nextX);
  607.         }
  608.     }
  609.     return layerChild;
  610. }
  611.  
  612.  
  613. function IndexInputEnable(bEnable)
  614. {
  615.     gbIndexInputEnable = bEnable;
  616.     return;
  617. }
  618.  
  619. function IndexInputSubmit()
  620. {
  621.     IndexLookup(true);
  622.     return;
  623. }
  624.  
  625. //Initize the site
  626. function IndexSiteInit()
  627. {
  628.   if (!window.Array) return;
  629.  
  630.   if (gbNav4) document.captureEvents(Event.KEYUP);
  631.   document.onkeyup = IndexLookupKeydown;
  632. }
  633.  
  634. function IndexLookupKeydown() 
  635. {
  636.     IndexLookup(false);
  637. }
  638.  
  639. function IndexLookup(bCR) 
  640. {
  641.     if (!parent.gbIndexLayerInit) {
  642.         return; 
  643.     }
  644.  
  645.     if (!gbIndexInputEnable && !gbMac) {
  646.         return;
  647.     }
  648.  
  649.     var strInput = document.IndexInputForm.keywordField.value.toUpperCase();
  650.     if (strInput != "") {
  651.         IndexSiteDisplay(strInput, bCR);
  652.     }
  653.  
  654.     if (gbMac) {
  655.         document.IndexInputForm.keywordField.focus();
  656.     }
  657.  
  658.     return;
  659. }
  660.  
  661. function  IndexSiteDisplay(strInput, bCR)
  662. {
  663.     // Get the topmost Index layer
  664.     var IndexDiv = IndexBody();
  665.  
  666.     // Get the layer for the first letter
  667.     var cFirst = strInput.charAt(0);
  668.     cFirst.toUpperCase();
  669.     var layerFirst = null;
  670.     if (gbNav4) {
  671.         for (var iLayer = 0; iLayer < document.layers.length; iLayer++) {
  672.             if ((document.layers[iLayer].id.indexOf("Parent") != -1) &&
  673.                 (document.layers[iLayer].id.charAt(0) == cFirst)) {
  674.                 layerFirst = document.layers[iLayer];
  675.                 break;
  676.             }
  677.         }
  678.         if (layerFirst == null) {
  679.             layerFirst = document.BookR0000000Parent;
  680.         }
  681.     } else if (gbIE4) {
  682.  
  683.         var iLetterIndex = cFirst.charCodeAt(0) - "A".charCodeAt(0) + 1;
  684.         if ((iLetterIndex < 1) || (iLetterIndex > 26)) {
  685.             layerFirst = IndexDiv.gIndexLetterArray[0];
  686.         } else {
  687.             layerFirst = IndexDiv.gIndexLetterArray[iLetterIndex];
  688.         }
  689.     }
  690.  
  691.     // If we didn't find anything then return - something went terribly wrong
  692.     if (layerFirst == null) {
  693.         return;
  694.     }
  695.  
  696.     // Expand the first layer
  697.     var strLayerID = layerFirst.id;
  698.     var iParent = strLayerID.indexOf("Parent");
  699.     strLayerID = strLayerID.substr(0, iParent);
  700.  
  701.     var layerChild = IndexDiv.IndexExpandIt(strLayerID, true);
  702.  
  703.     // Find the first child that "matches" the item we are searchig for
  704.     var MatchingItem = null;
  705.     if (gbNav4) {
  706. //        for (var iLayer = 0; iLayer < layerChild.layers.length; iLayer++) {
  707. //            alert(layerChild.layers[iLayer].id);
  708. //        }
  709.     } else if (gbIE4) {
  710.  
  711.         var tempColl = layerChild.all.tags("P");
  712.         if (tempColl.length == 0) {
  713.             MatchingItem = layerChild;
  714.         } else {
  715.             var iStart = 0;
  716.             var iEnd = tempColl.length - 1;
  717.             var iMid = 0;
  718.             var strItemUpper = "";
  719.             while (iStart <= iEnd) {
  720.                 iMid = iStart + iEnd;
  721.                 iMid >>= 1;
  722.                 strItemUpper = tempColl(iMid).innerText;
  723.                 strItemUpper = strItemUpper.toUpperCase();
  724.                 if (strItemUpper.indexOf(strInput) == 0) {
  725.                     break;
  726.                 } else if (strItemUpper > strInput) {
  727.                     iEnd = iMid - 1;
  728.                 } else {
  729.                     iStart = iMid + 1;
  730.                 }
  731.             }
  732.  
  733.             // Search backward to find the first one that partially matches
  734.             var iMatch = 0;
  735.             for (var iMatch = iMid; iMatch >= 0; iMatch--) {
  736.                 strItemUpper = tempColl(iMatch).innerText;
  737.                 strItemUpper = strItemUpper.toUpperCase();
  738.                 if (strItemUpper.indexOf(strInput) != 0) {
  739.                     break;
  740.                 }
  741.             }
  742.             if (iMatch != iMid) {
  743.                 if (iMatch >= 0) {
  744.                     if (iMatch < tempColl.length - 1) {
  745.                         iMid = iMatch + 1;
  746.                     } else {
  747.                         iMid = iMatch;
  748.                     }
  749.                 } else {
  750.                     iMid = 0;
  751.                 }
  752.             }
  753.             MatchingItem = tempColl(iMid);
  754.         }
  755.     }
  756.  
  757.     // Scroll to the closest matching item
  758.     if (MatchingItem) {
  759.         if (gbNav4) {
  760.         } else if (gbIE4) {
  761.             IndexDiv.document.body.scrollTop = MatchingItem.offsetTop;
  762.  
  763.             // Set the focus on the selected hyperlink (if there is one)
  764.             if (gbIE5) {
  765.                 tempColl = MatchingItem.all.tags("A");
  766.                 if (tempColl.length > 0) {
  767.                     // If a carriage return was used then simulate a click
  768.                     if (bCR) {
  769.                         tempColl(0).click();
  770.                     } else {
  771.                         // Simply set the focus to the hyperlink
  772.                         tempColl(0).focus();
  773.                     }
  774.                     IndexForm().document.IndexInputForm.keywordField.focus();
  775.                 }
  776.             }
  777.         }
  778.     }
  779.  
  780.     return;
  781. }
  782.  
  783. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  784. //
  785. // TOC code
  786. //
  787. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  788. var imgBookClose ="bssctoc1.gif";
  789. var imgBookOpen  ="bssctoc2.gif";
  790.  
  791. var  elTocArray = new Array();
  792. var  elTocArrayNum = 0;
  793.  
  794. function TocWriteClassStyle()
  795. {
  796.     document.write("<STYLE TYPE='text/css'>");
  797.     if (gbNav4) {
  798.         document.write(".parent {position:absolute; visibility:hidden}");
  799.         document.write(".child {position:absolute; visibility:hidden}");
  800.         document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:-15pt;}");
  801.         document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  802.         document.write("P {margin-top:0pt; margin-bottom:0pt}");
  803.         document.write("PRE {margin-top:0pt; margin-bottom:0pt}");
  804.     } else if (gbIE4) {
  805.         if (gbMac) {
  806.             document.write(".parent {font-size:14pt;}");
  807.             document.write("P {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  808.             document.write("PRE {font-family:'Arial'; font-size:12pt; margin-top:0pt; margin-bottom:0pt;}");
  809.             if (gbIE5){
  810.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  811.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  812.             } else {
  813.                 document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  814.                 document.write("DIV {margin-top:0pt; margin-bottom:0pt;}");
  815.             }
  816.         } else {
  817.             document.write(".parent {font-size:10pt;}");
  818.             document.write("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt; margin-left:15pt;}");
  819.             document.write("P {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  820.             document.write("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
  821.             document.write("DIV {margin-top:0pt; margin-bottom:0pt}");
  822.         }
  823.         document.write(".child {display:none}");
  824.         document.write("A:link {text-decoration: none; color: 000000}");
  825.         document.write("A:visited {text-decoration: none; color: 333333}");
  826.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  827.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  828.     }
  829.     document.write("</STYLE>");
  830.     return;
  831. }
  832.  
  833. function TocWriteFixedWidth(bBegin, nWidth)
  834. {
  835.     //Avoid the wrap of text after book/page, make a invisble outter table is approch (for IE4 iMac only)
  836.     if ((gbIE4) && (gbMac))    {
  837.         if (bBegin)    {
  838.             document.write("<table width=" + nWidth +" border=0><tr><td>");
  839.         } else    {
  840.             document.write("</td></tr></table>");
  841.         }
  842.     }
  843. }
  844.  
  845. //Assign the layer's visibility at initialize the Page
  846. function TocInitPage()
  847. {
  848. //    var TocDiv = NavFrame().FindTopLevelLayer('TocNav');
  849. //    if (TocDiv != null) {
  850. //        return;
  851. //    }
  852.     if (gbNav4) {
  853. //        for (var i=0; i < document.layers.length; i++) {
  854. //            var whichEl = document.layers[i];
  855. //            if (whichEl.id.indexOf("Child") != -1) {
  856. //                whichEl.visibility = "hide";
  857. //            } else {
  858. //                whichEl.visibility = "show";
  859. //            }
  860. //        }
  861.         TocBuildLayerArrayNS();
  862.         onLoad  = TocArrangeAllLayerNS();
  863.     } else if (gbIE4) {
  864.  
  865.         // Select the first hyperlink
  866.         var tempColl = document.all.tags("A");
  867.         if (tempColl.length > 0) {
  868.             tempColl(0).focus();
  869.         }
  870.     }
  871.     return;
  872. }
  873.  
  874. function TocShowLayer(whichEl, bShow)
  875. {
  876.     if (bShow) {
  877.         whichEl.visibility = "show";
  878.     } else {
  879.         whichEl.visibility = "hide";
  880.     }
  881.     for (var i=0; i<whichEl.document.layers.length; i++) {
  882.         var whichChildEl = whichEl.document.layers[i];
  883.         ShowLayer(whichChildEl, bShow);
  884.     }
  885. }
  886.  
  887. function TocExpandAll()
  888. {
  889.     for (var i=0; i<document.layers.length; i++) {
  890.         var whichEl = document.layers[i];
  891.         TocShowLayer(whichEl, true);
  892.     }
  893.     TocBuildLayerArrayNS();
  894.     TocArrangeAllLayerNS();
  895.  
  896.     return;
  897. }
  898.  
  899. function TocCollapseAll()
  900. {
  901.     for (var i=0; i<document.layers.length; i++) {
  902.         var whichEl = document.layers[i];
  903.         ShowLayer(whichEl, false);
  904.         if (whichEl.id.indexOf("Child") != -1) {
  905.             whichEl.visibility = "hide";
  906.         } else {
  907.             whichEl.visibility = "show";
  908.         }
  909.     }
  910.     TocBuildLayerArrayNS();
  911.     TocArrangeAllLayerNS();
  912.  
  913.     return;
  914. }
  915.  
  916.  
  917. //Expand a layer
  918. function TocExpandIt(elId)
  919. {
  920.     if (gbIE4) {
  921.         var child = TocExpandIE(elId, true, false);
  922.         var nNewScroll = document.body.scrollTop;
  923.         if (child.style.display == "block") {
  924.             var nItemTop = child.offsetTop;
  925.             var nItemBottom = nItemTop + child.offsetHeight;
  926.             // Make sure the bottom is visible if possible
  927.             if (document.body.scrollTop + document.body.clientHeight < nItemBottom) {
  928.                 nNewScroll = nItemBottom - document.body.clientHeight;
  929.             }
  930.             // If expanded item is bigger than the client area, scroll the item to the top
  931.             if (nItemBottom - nItemTop > document.body.clientHeight) {
  932.                 nNewScroll = nItemTop - 20;
  933.             }
  934.         }
  935.         document.body.scrollTop = nNewScroll;
  936.     } else if (gbNav4) {
  937.         TocExpandNS(elId, true, false);
  938.         if (window.NSscrollbar != null) {
  939.             window.NSscrollbar.SetContentHeight(nextY);
  940.             window.NSscrollbar.SetContentWidth(nextX);
  941.         }
  942.     }
  943.     return;
  944. }
  945.  
  946.  
  947. ////////////////////////////////////////////////////////////////
  948. //Functions for IE
  949. function TocExpandIE(elId, bChangeImg, bForceOpen) 
  950.     var whichEl = eval(elId + "Child");
  951.     var whichIm = document.images[elId];
  952.  
  953.     if (whichEl == null) {
  954.         return null;
  955.     }
  956.  
  957.     if ((whichEl.style.display != "block") || bForceOpen) {
  958.         whichEl.style.display = "block";
  959.         if (bChangeImg) {
  960.             whichIm.src = imgBookOpen;        
  961.         }
  962.     } else {
  963.         whichEl.style.display = "none";
  964.         if (bChangeImg) {
  965.             whichIm.src = imgBookClose;
  966.         }
  967.         if (gbMac) {
  968.             //YJ: ?? can not scroll into view, if div has fixed width, it will scroll horizal to the very end.
  969.             //whichEl.scrollIntoView(false);
  970.         }
  971.     }
  972.     return whichEl;
  973. }
  974.  
  975. ////////////////////////////////////////////////////////////////
  976. //Functions for NS
  977. function TocExpandNS(elId, bChangeImg, bForceOpen)
  978. {
  979.     var whichParent = null;
  980.     var whichChild  = null;
  981.     var idParent = elId + "Parent";
  982.     var idChild  = elId + "Child";
  983.     for (var i=0; i<elTocArrayNum ;i++) {
  984.         if  (idParent == elTocArray[i].id) {
  985.             whichParent = elTocArray[i].el;
  986.  
  987.             if ((i+1 < elTocArrayNum) && (idChild == elTocArray[i+1].id))
  988.             {
  989.                 whichChild = elTocArray[i+1].el;
  990.             }
  991.             break;
  992.         }
  993.     }
  994.     if (whichParent == null)    return null;
  995.     var imgParent = whichParent.document.images[0];
  996.     if (whichChild == null) return null;
  997.  
  998.     if (whichChild.visibility == "hide")
  999.     {
  1000.         whichChild.visibility = "show";
  1001.         if (bChangeImg) {
  1002.             imgParent.src = imgBookOpen;
  1003.         }
  1004.         for (var i=0; i<whichChild.layers.length; i++)
  1005.         {
  1006.             var whichEl = whichChild.layers[i];
  1007.             if (whichEl.id.indexOf("Parent") != -1)
  1008.                 whichEl.visibility = "show";
  1009.         }
  1010.     }
  1011.     else if (bForceOpen)
  1012.     {
  1013.         return whichChild;
  1014.     }
  1015.     else
  1016.     {
  1017.         whichChild.visibility = "hide";
  1018.         if (bChangeImg) {
  1019.             imgParent.src = imgBookClose;
  1020.         }
  1021.         for (var i=0; i<whichChild.layers.length; i++)
  1022.         {
  1023.             var whichEl = whichChild.layers[i];
  1024.             whichEl.visibility = "hide";
  1025.         }
  1026.     }
  1027.     TocArrangeAllLayerNS(bChangeImg);
  1028.     return whichChild;
  1029. }
  1030.  
  1031. function elTocLayerNS(elLayer, elLayerId)
  1032. {
  1033.     this.el  = elLayer;
  1034.     this.id  = elLayerId;
  1035.     return;
  1036. }
  1037.  
  1038. function TocFindLayerNS(elLayer)
  1039. {
  1040.     for (var i = 0; i < elLayer.layers.length; i++) {
  1041.         var whichEl = elLayer.layers[i];
  1042. //        if (typeof whichEl != "undefined") {
  1043.         if ((whichEl.id.indexOf("Parent") != -1) ||
  1044.             (whichEl.id.indexOf("Child") != -1)) {
  1045.             elTocArray[elTocArrayNum] = new elTocLayerNS(whichEl,whichEl.id);
  1046.             elTocArrayNum++;
  1047.             TocFindLayerNS(whichEl);
  1048.         }
  1049.     }
  1050.     return;
  1051. }
  1052.  
  1053. function TocBuildLayerArrayNS()
  1054. {
  1055.     elTocArrayNum = 0;
  1056.     TocFindLayerNS(document);
  1057.     return;
  1058. }
  1059.  
  1060. var  nextY = 0;
  1061. var  nextX = 0; // real means : the maxium width of sub-layers' width
  1062. function TocArrangeLayerNS(elLayer, bShowLayer, iLevel, bChangeImg)
  1063. {
  1064.     var i = 0;
  1065.     while (i < elLayer.layers.length)
  1066.     {
  1067.         var whichParent = elLayer.layers[i];
  1068.         
  1069.         if (whichParent.id.indexOf("Parent") == -1) 
  1070.             i++; // Check to make sure this is a "parent" because we do have extra layers on the page
  1071.         else
  1072.         {
  1073.             var whichChild  = elLayer.layers[i+1];
  1074.             if (bShowLayer)
  1075.             {   // Check to see if we have a second (or lower level) block with pages
  1076.                 // on top of books. If so, Netscape would ordinarily add space for the
  1077.                 // BLOCKQUOTE, but we don't want one - so remove the space.
  1078.                 if( (i == 0) && (iLevel > 0) &&
  1079.                     (null != whichParent.parentLayer) &&
  1080.                     (whichParent.parentLayer.document.images.length > 0))
  1081.                     nextY -= whichParent.document.height;
  1082.  
  1083.                 whichParent.pageY = nextY;
  1084.                 whichParent.visibility = "show";
  1085.  
  1086.                 whichParent.clip.bottom = whichParent.document.height;
  1087.                 whichParent.clip.right  = whichParent.document.width + iLevel*20;// plus indent width
  1088.                 if( whichParent.clip.right > nextX )
  1089.                     nextX = whichParent.clip.right;
  1090.  
  1091.                 nextY += whichParent.document.height;
  1092.                 if (whichChild.visibility == "show")
  1093.                 {
  1094.                     if (bChangeImg)
  1095.                         whichParent.document.images[0].src = imgBookOpen;
  1096.  
  1097.                     whichChild.pageY = nextY;
  1098.                     nextY += whichChild.document.height;
  1099.  
  1100.                     whichChild.clip.right = whichChild.document.width + iLevel*20;// plus indent width
  1101.                     if( whichChild.clip.right > nextX )
  1102.                         nextX = whichChild.clip.right;
  1103.  
  1104.                     TocArrangeLayerNS(whichChild, true, iLevel + 1, bChangeImg);
  1105.                     whichChild.clip.bottom = nextY - window.NSscrollbar.GetContentVerticalPos();
  1106.                     if( nextX > whichChild.clip.right )
  1107.                         whichChild.clip.right = nextX;
  1108.                 }
  1109.                 else
  1110.                 {
  1111.                     if (bChangeImg)
  1112.                         whichParent.document.images[0].src = imgBookClose;
  1113.  
  1114.                     TocArrangeLayerNS(whichChild, false, iLevel + 1, bChangeImg);
  1115.                 }
  1116.             }
  1117.             else
  1118.             {
  1119.                 if (bChangeImg)
  1120.                     whichParent.document.images[0].src = imgBookClose;
  1121.                 whichParent.visibility = "hide";
  1122.                 whichParent.clip.bottom = 0;
  1123.                 whichParent.clip.right  = 0;
  1124.  
  1125.                 whichChild.visibility = "hide";
  1126.                 whichChild.clip.bottom = 0;
  1127.                 whichChild.clip.right  = 0;
  1128.                 TocArrangeLayerNS(whichChild, false, iLevel, bChangeImg);
  1129.             }
  1130.             i += 2;
  1131.         }
  1132.     }
  1133.     return;
  1134. }
  1135.  
  1136. function TocArrangeAllLayerNS(bChangeImg) 
  1137. {
  1138.     if (document.layers.length > 0) {
  1139.         nextX = document.layers[0].pageX;
  1140.         nextY = document.layers[0].pageY;
  1141.         TocArrangeLayerNS(document, true, 0, bChangeImg);
  1142.     }
  1143.     return;
  1144. }
  1145.  
  1146. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1147. //
  1148. // FTS code
  1149. //
  1150. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  1151.  
  1152. function FtsWriteClassStyle()
  1153. {
  1154.     document.write("<STYLE TYPE='text/css'>");
  1155.     if (gbNav4) {
  1156.         document.write("P {font-family:'Arial'; font-size:9pt;}");
  1157.         document.write("A:link {text-decoration: none; color: 000000}");
  1158.         document.write("A:visited {text-decoration: none; color: 333333}");
  1159.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1160.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1161.     } else if (gbIE4) {
  1162.         if (gbMac) {
  1163.             document.write("P {font-family:'Arial'; font-size:12pt;}");
  1164.             document.write("dt {font-family:'Arial'; font-size:12pt;}");
  1165.         } else {
  1166.             document.write("P {font-family:'Arial'; font-size:9pt;}");
  1167.             document.write("dt {font-family:'Arial'; font-size:9pt;}");
  1168.         }
  1169.         document.write("A:link {text-decoration: none; color: 000000}");
  1170.         document.write("A:visited {text-decoration: none; color: 333333}");
  1171.         document.write("A:active {text-decoration: none; background-color: #cccccc}");
  1172.         document.write("A:hover {text-decoration: underline; color: 007f00}");
  1173.     }
  1174.     document.write("</STYLE>");
  1175.     return;
  1176. }
  1177.  
  1178. //Define variable arguments as: strKeyword [,strTopicIndex]*
  1179. //function KeywordEntry()
  1180. function FtsKeywordEntry() 
  1181. {
  1182.     var argLen = FtsKeywordEntry.arguments.length;
  1183.     this.strKeyword = FtsKeywordEntry.arguments[0];
  1184.     this.arrayTopics = new Array();
  1185.  
  1186.     // Now add all of the topic entries
  1187.     for (var i=0; i < argLen - 1; i++) {
  1188.         this.arrayTopics[i] = FtsKeywordEntry.arguments[i + 1];
  1189.     }
  1190. }
  1191.  
  1192. function FtsStopWord()
  1193. {
  1194.     this.strStopWord = FtsStopWord.arguments[0];
  1195. }
  1196.  
  1197. function FtsInputEnable(bEnable)
  1198. {
  1199.    gbFtsInputEnable = bEnable;
  1200.    return;
  1201. }
  1202.  
  1203. function FtsInputSubmit()
  1204. {
  1205.     FtsLookup();
  1206.     return false;
  1207. }
  1208.  
  1209. //Initize the site
  1210. function FtsInit()
  1211. {
  1212.   if (!window.Array) return;
  1213.  
  1214. //  if (gbNav4) document.captureEvents(Event.KEYUP);
  1215. //  document.onkeyup = FtsLookup;
  1216. }
  1217.  
  1218. function FtsLookup() 
  1219. {
  1220.     if (!gbFtsInputEnable && !gbMac)
  1221.         return;
  1222.  
  1223.     var strInput = document.FtsInputForm.ftsField.value.toLowerCase();
  1224.     if (strInput != "") {
  1225.         FtsDisplay(strInput);
  1226.     }
  1227.  
  1228.     if (gbMac) {
  1229.         document.FtsInputForm.ftsField.focus();
  1230.     }
  1231. }
  1232.  
  1233. var gstrDisplayInput = "";
  1234.  
  1235. function FtsFindTable()
  1236. {
  1237.     // Get the appropriate item to add items to
  1238.     var layerFind = null;
  1239.     if (gbIE4) {
  1240.         layerFind = parent.document.frames['ftsbody'].document.all.FtsFindTable;
  1241.     } else if (gbNav4) {
  1242.         layerFind = parent.document.ftsbody.document.FtsFindTable.document;
  1243.     }
  1244.     
  1245.     return layerFind;
  1246. }
  1247.  
  1248. function FtsBody()
  1249. {
  1250.     // Get the appropriate item to add items to
  1251.     var layerFind = null;
  1252.     if (gbIE4) {
  1253.         layerFind = parent.document.frames['ftsbody'];
  1254.     } else if (gbNav4) {
  1255.         layerFind = parent.document.ftsbody.document;
  1256.     }
  1257.     
  1258.     return layerFind;
  1259. }
  1260.  
  1261. function FtsDisplay(strInput)
  1262. {
  1263.     var layerFind = FtsFindTable();
  1264.     if (layerFind == null) {
  1265.         return;
  1266.     }
  1267.  
  1268.     // Let the user know we are busy
  1269.     var strHtm = "<P><B><FONT SIZE=2>Finding topics...</FONT></B></P>"
  1270.     if (gbIE4) {
  1271.         layerFind.innerHTML = strHtm;
  1272.     } else if (gbNav4) {
  1273.         layerFind.write(strHtm);
  1274.         layerFind.close();
  1275.     }
  1276.     window.gstrDisplayInput = strInput;
  1277.     setTimeout("FtsDisplayReal()", 50);
  1278.  
  1279.     return;
  1280. }
  1281.  
  1282. function FtsDisplayReal()
  1283. {
  1284.     var FtsDiv = FtsBody();
  1285. //    if (gbNav4) {
  1286. //        FtsDiv = FindTopLevelLayer('FtsNav');
  1287. //    } else if (gbIE4) {
  1288. //        FtsDiv = parent.parent.FindTopLevelLayer('FtsNav');
  1289. //        FtsDiv = FtsDiv.document.frames['FtsIFrame'].document.all.ftsbody;
  1290. //    }
  1291.  
  1292.     var strInput = window.gstrDisplayInput;
  1293.     var nKeywordArrayLen = FtsDiv.gFtsKeywordArray.length;
  1294.     var nTopicArrayLen = FtsDiv.gFtsTopicArray.length;
  1295.     var nStopArrayLen = FtsDiv.gFtsStopArray.length;
  1296.  
  1297.     // Get the appropriate item to add items to
  1298.     var layerFind = FtsFindTable();
  1299.     if (layerFind == null) {
  1300.         return;
  1301.     }
  1302.  
  1303.     // Keep track of which operation we are currently in
  1304.     // 0 = OR; 1 = AND
  1305.     var nCurrentOp = 0;
  1306.     var bNot = false;
  1307.  
  1308.     // Loop through the words in the input string
  1309.     var bFinished = false;
  1310.     var bFirstKeyword = true;
  1311.     var strCurrentWord = "";
  1312.     var strCurrentStem = "";
  1313.     var strKeyword = "";
  1314.     var strHtm = "";
  1315.     var nFirstMatch = -1;
  1316.     var nLastMatch  = -1;
  1317.     var i=0;
  1318.     var iSpace = 0;
  1319.     var iFound = 0;
  1320.     var SearchTopicArray = new Array();
  1321.     var iSearch = 0;
  1322.     // If you change this Word Break string make sure you also change it in FtsDataBase.CPP
  1323.     var FTS_WORD_BREAK_CHARS = "\t\r\n\"\\ .,!@#$%^&*()~'`:;<>?/{}[]|+-=\x85\x92\x93\x94\x95\x96\x97\x99\xA9\xAE\xB7";
  1324.     var nNumWordBreakChars = FTS_WORD_BREAK_CHARS.length;
  1325.  
  1326.     // Clear the flags for each of the topics
  1327.     var iTopic = 0;
  1328.     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1329.         SearchTopicArray[iTopic] = 0;
  1330.     }
  1331.  
  1332.     while (!bFinished) {
  1333.  
  1334.         // Get the next word
  1335.         iSpace = -1;
  1336.         iChar = 0;
  1337.         iSep = -1;
  1338.         for (var iChar = 0; iChar < nNumWordBreakChars; iChar++) {
  1339.             iFound = strInput.indexOf(FTS_WORD_BREAK_CHARS.charAt(iChar));
  1340.             if ((iFound != -1) && ((iSpace == -1) || (iFound < iSpace))) {
  1341.                 iSpace = iFound;
  1342.                 iSep = iChar;
  1343.             }
  1344.         }
  1345.         if (iSpace == -1) {
  1346.             strCurrentWord = strInput;
  1347.             strInput = "";
  1348.         } else {
  1349.             strCurrentWord = strInput.substr(0, iSpace);
  1350.             strInput = strInput.substr(iSpace + 1);
  1351.         }
  1352.  
  1353.         // Check for operators or a blank word
  1354.         if ((strCurrentWord == "or") ||
  1355.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "|"))) {
  1356.             nCurrentOp = 0;
  1357.             bNot = false;
  1358.         } else if ((strCurrentWord == "and") ||
  1359.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "&"))) {
  1360.             nCurrentOp = 1;
  1361.             bNot = false;
  1362.         } else if ((strCurrentWord == "not") ||
  1363.                ((iSep >= 0) && (FTS_WORD_BREAK_CHARS.charAt(iSep) == "~"))) {
  1364.             bNot = true;
  1365.         } else if (strCurrentWord == "") {
  1366.             if (strInput == "") {
  1367.                 break;
  1368.             } else {
  1369.                 continue;
  1370.             }
  1371.         } else if (!IsStopWord(strCurrentWord, FtsDiv.gFtsStopArray, nStopArrayLen)){
  1372.  
  1373.             // See if this is has a NOT at the beginning
  1374.             if (strCurrentWord.substr(0, 1) == "~") {
  1375.                 bNot = true;
  1376.                 strCurrentWord = strCurrentWord.substr(1);
  1377.             }
  1378.  
  1379.             // Get the stemmed version of the word
  1380.             strCurrentStem = GetStem(strCurrentWord);
  1381.  
  1382.             // See if the stemmed word is found in the list
  1383.             iFound = -1;
  1384.             iFound = FtsFindKeyword(strCurrentStem, FtsDiv.gFtsKeywordArray, nKeywordArrayLen);
  1385.  
  1386.             // Did we find the keyword?
  1387.             if (iFound != -1) {
  1388. //                alert("found " + strCurrentWord);
  1389.  
  1390.                 // See if we are performing an OR operation
  1391.                 var nNumTopics = FtsDiv.gFtsKeywordArray[iFound].arrayTopics.length;
  1392.                 if (nCurrentOp == 0) {
  1393.                     if (bNot) {
  1394.                         var cFoundArrayTopics =  FtsDiv.gFtsKeywordArray[iFound].arrayTopics;
  1395.                         // Add all topics that are not in the list for this keyword
  1396.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1397.                             // See if the topic is in the list for this keyword
  1398.                             for (iListTopic = 0; iListTopic < nNumTopics; iListTopic++) {
  1399.                                 if (cFoundArrayTopics[iListTopic] == iTopic) {
  1400.                                     break;
  1401.                                 }
  1402.                             }
  1403.                             if (iListTopic == nNumTopics) {
  1404.                                 // The topic is not in the list for the current keyword, so add it
  1405.                                 SearchTopicArray[iTopic] = 1;
  1406.                             }
  1407.                         }
  1408.  
  1409.                     } else {
  1410.                         // Loop through the topics that have the keyword and add them to the list
  1411.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1412.                             var nTopicNum = FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic];
  1413.                             // Add the topic to the list
  1414.                             SearchTopicArray[nTopicNum] = 1;
  1415.                         }
  1416.                     }
  1417.                 // See if this is an AND operation
  1418.                 } else if (nCurrentOp == 1) {
  1419.  
  1420.                     if (bNot) {
  1421.                         // Loop through the topics for the current word and remove them from the list
  1422.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1423.                             SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = 0;
  1424.                         }
  1425.                     } else {
  1426.                         // Loop through the topics already in the list and remove them if they are not
  1427.                         // in the list for the current word
  1428.                         for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1429.                             if (SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] == 1) {
  1430.                                 SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = -1;
  1431.                             }
  1432.                         }
  1433.                         for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1434.                             if (SearchTopicArray[iTopic] == -1) {
  1435.                                 SearchTopicArray[iTopic] = 1;
  1436.                             } else {
  1437.                                 SearchTopicArray[iTopic] = 0;
  1438.                             }
  1439.                         }
  1440.                     }
  1441.                 }
  1442.             } else {
  1443.                 // Word was not found
  1444.  
  1445.                 // Clear the list if this is an AND operation
  1446.                 if ((nCurrentOp == 1) && (!bNot)) {
  1447.                     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1448.                         SearchTopicArray[iSearch] = 0;
  1449.                     }
  1450.  
  1451.                 // Add all items to the list if this is an OR operation with a NOT operator
  1452.                 } else if ((nCurrentOp == 0) && (bNot)) {
  1453.  
  1454.                     // Add all topics that are not in the list for this keyword
  1455.  
  1456.                     // First set all flags to -1 if they are not already set
  1457.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1458.                         if (SearchTopicArray[iTopic] == 0) {
  1459.                             SearchTopicArray[iTopic] = -1;
  1460.                         }
  1461.                     }
  1462.  
  1463.                     // Now clear all -1s for topics associated with this keyword
  1464.                     for (iTopic = 0; iTopic < nNumTopics; iTopic++) {
  1465.                         if (SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] == -1) {
  1466.                             SearchTopicArray[FtsDiv.gFtsKeywordArray[iFound].arrayTopics[iTopic]] = 0;
  1467.                         }
  1468.                     }
  1469.  
  1470.                     // Finally change all -1s to 1s
  1471.                     for (iTopic = 0; iTopic < nTopicArrayLen; iTopic++) {
  1472.                         if (SearchTopicArray[iTopic] == -1) {
  1473.                             SearchTopicArray[iTopic] = 1;
  1474.                         }
  1475.                     }
  1476.                 }
  1477.             }
  1478.  
  1479.             // If this was the first word change the operation to "and". We need to have it be
  1480.             // an "or" for the first keyword so we would add the items for the first search word.
  1481.             if (bFirstKeyword) {
  1482.                 bFirstKeyword = false;
  1483.                 nCurrentOp = 1;
  1484.             }
  1485.         }
  1486.     }
  1487.  
  1488.     var aSortedTopics = new Array();
  1489.     var nNumSortTopics = 0;
  1490.     for (iSearch = 0; iSearch < nTopicArrayLen; iSearch++) {
  1491.         if (SearchTopicArray[iSearch]) {
  1492.             aSortedTopics[nNumSortTopics++] = iSearch;
  1493.         }
  1494.     }
  1495.  
  1496.     // Limit the number of topics in the result set
  1497.     if (nNumSortTopics > 75) {
  1498.         nNumSortTopics = 75;
  1499.     }
  1500.  
  1501. //    alert("Num Topics in Search array: " + nNumTopicsInSearch);
  1502.     // Sort the topics by title
  1503.     SortTopics(FtsDiv, aSortedTopics, 0, nNumSortTopics - 1);
  1504.  
  1505.     // Add hyperlinks for all of the found topics
  1506.     var strLine = "";
  1507.     for (iSearch = 0; iSearch < nNumSortTopics; iSearch++) {
  1508.         i = aSortedTopics[iSearch];
  1509.         if (i != -1) {
  1510.             strLine = "<dt><nobr><a href='" + FtsDiv.gFtsTopicArray[i].strURL + "'>";
  1511.             strLine += FtsDiv.gFtsTopicArray[i].strTitle; 
  1512.             strLine += "</a></nobr></dt>";
  1513.             strHtm += strLine;
  1514.         }
  1515.     }
  1516.  
  1517.     // Give a special message if none were found
  1518.     if (strHtm == "") {
  1519.         strHtm = "<P><B>No topics found.</B></P>"
  1520.     } else {
  1521.         strHtm = "<dl>" + strHtm + "</dl>";
  1522.     }
  1523.  
  1524.     if (gbIE4) {
  1525.         layerFind.innerHTML = strHtm;
  1526.     } else if (gbNav4) {
  1527.         layerFind.write(strHtm);
  1528.         layerFind.close();
  1529.     }
  1530.  
  1531.     return;
  1532. }
  1533.  
  1534.  
  1535. function FtsFindKeyword(strCurrentWord, aFtsKeywordArray, nKeywordArrayLen)
  1536. {
  1537.     // Search for the current word in the array (binary search)
  1538. //            alert("search for: " + strCurrentWord);
  1539.     var nLow = 0; 
  1540.     var nHigh = nKeywordArrayLen - 1;
  1541.     var nMid = 0;
  1542.     var bFound = false;
  1543.     var strKeyword = "";
  1544.     while (nLow <= nHigh) {
  1545.         nMid = (nLow + nHigh);
  1546.         nMid >>= 1;
  1547.         strKeyword = aFtsKeywordArray[nMid].strKeyword;
  1548. //                alert("low: " + nLow + "   high: " + nHigh + "  mid: " + nMid);
  1549. //                alert("search: " + strCurrentWord + "    Keyword: " + strKeyword);
  1550.         if (strCurrentWord > strKeyword) {
  1551.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1552.         } else {
  1553.             if (strCurrentWord < strKeyword)  {
  1554.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1555.             } else {
  1556.                 bFound = true;
  1557.                 break;
  1558.             }
  1559.         }
  1560.     }
  1561.  
  1562.     if (bFound) {
  1563.         return nMid;
  1564.     } else {
  1565.         return -1;
  1566.     }
  1567. }
  1568.  
  1569.  
  1570. // QuickSort
  1571. function SortTopics(FtsDiv, SearchTopicArray, nStart, nEnd)
  1572. {
  1573.     if (nEnd - nStart > 0) {
  1574.         var nLastLow = nStart;
  1575.  
  1576.         // Get the first value into its proper spot
  1577.         for (var i = nStart + 1; i <= nEnd; i++) {
  1578.             if ((SearchTopicArray[i] != -1) && (SearchTopicArray[nStart] != -1) &&
  1579.                 (FtsDiv.gFtsTopicArray[SearchTopicArray[i]].strTitle < FtsDiv.gFtsTopicArray[SearchTopicArray[nStart]].strTitle)) {
  1580.                 nLastLow++;
  1581.                 temp = SearchTopicArray[i];
  1582.                 SearchTopicArray[i] = SearchTopicArray[nLastLow];
  1583.                 SearchTopicArray[nLastLow] = temp;
  1584.             }
  1585.         }
  1586.         temp = SearchTopicArray[nStart];
  1587.         SearchTopicArray[nStart] = SearchTopicArray[nLastLow];
  1588.         SearchTopicArray[nLastLow] = temp;
  1589.  
  1590.         // Sort the two halves of this array surrounding the new spot for the first value
  1591.         SortTopics(FtsDiv, SearchTopicArray, nStart, nLastLow);
  1592.         SortTopics(FtsDiv, SearchTopicArray, nLastLow + 1, nEnd);
  1593.     }
  1594. }
  1595.  
  1596. function IsStopWord(strCurrentWord, aFtsStopArray, nStopArrayLen)
  1597. {
  1598.     // Search for the current word in the array (binary search)
  1599.     var nLow = 0; 
  1600.     var nHigh = nStopArrayLen - 1;
  1601.     var nMid = 0;
  1602.     var bFound = false;
  1603.     var strStopWord = "";
  1604.     while (nLow <= nHigh) {
  1605.         nMid = (nLow + nHigh);
  1606.         nMid >>= 1;
  1607.         strStopWord = aFtsStopArray[nMid].strStopWord;
  1608.         if (strCurrentWord > strStopWord) {
  1609.             nLow = (nLow == nMid) ? nMid + 1 : nMid;
  1610.         } else {
  1611.             if (strCurrentWord < strStopWord) {
  1612.                 nHigh = (nHigh == nMid) ? nMid - 1: nMid;
  1613.             } else {
  1614.                 bFound = true;
  1615.                 break;
  1616.             }
  1617.         }
  1618.     }
  1619.  
  1620.     if (bFound) {
  1621.         return true;
  1622.     } else {
  1623.         return false;
  1624.     }
  1625. }
  1626.  
  1627.  
  1628. /////////////////////////////////////////////////////////////
  1629. //
  1630. // NOTE: If you change this function, you should also change
  1631. // it in the FtsDatabase.CPP file
  1632. //
  1633. /////////////////////////////////////////////////////////////
  1634. function GetStem(szWord)
  1635. {
  1636.     var aStems = new Array();
  1637.     aStems[0] = "ed";
  1638.     aStems[1] = "es";
  1639.     aStems[2] = "er";
  1640.     aStems[3] = "e";
  1641.     aStems[4] = "s";
  1642.     aStems[5] = "ingly";
  1643.     aStems[6] = "ing";
  1644.     aStems[7] = "ly";
  1645.  
  1646.     // Loop through all the stems
  1647.     var nNumStems = aStems.length;
  1648.     var    nStemPos = 0;
  1649.     var csStem = "";
  1650.     var csSubString = "";
  1651.     for (var iStem = 0; iStem < nNumStems; iStem++) {
  1652.  
  1653.         // Get the "would be" position of the stem in the word and see
  1654.         // if this word has the stem
  1655.         nStemPos = szWord.lastIndexOf(aStems[iStem]);
  1656.         if (nStemPos > 0) {
  1657.             csSubString = szWord.substring(nStemPos);
  1658.             if (csSubString == aStems[iStem]) {
  1659.                 
  1660.                 // Found a stem
  1661.  
  1662.                 // Check for double consonant
  1663.                 csStem = szWord;
  1664.                 if (szWord.charAt(nStemPos - 2) == szWord.charAt(nStemPos - 1)) {
  1665.                     csStem = csStem.substring(0, nStemPos - 1);
  1666.                 } else {
  1667.                     csStem = csStem.substring(0, nStemPos);
  1668.                 }
  1669.                 return csStem;
  1670.             }
  1671.         }
  1672.     }
  1673.  
  1674.     // No stem found
  1675.     csStem = szWord;
  1676.     return csStem;
  1677. }
  1678.  
  1679. ////////////////////////////////////////////////////////////////////////////////////////////////
  1680. //
  1681. // Navgation Bar Code
  1682. //
  1683. ////////////////////////////////////////////////////////////////////////////////////////////////
  1684.  
  1685. function NavBar_SelectTOC()
  1686. {
  1687.     var frameLeft = null
  1688.     if (gbNav4) {
  1689.         frameLeft = window.parent.left;
  1690.     } else {
  1691.         frameLeft = window.parent.frames("left");
  1692.     }
  1693.     frameLeft.ChangeToTOC();
  1694. }
  1695.  
  1696. function NavBar_SelectIndex()
  1697. {
  1698.     var frameLeft = null
  1699.     if (gbNav4) {
  1700.         frameLeft = window.parent.left;
  1701.     } else {
  1702.         frameLeft = window.parent.frames("left");
  1703.     }
  1704.     frameLeft.ChangeToIndex();
  1705. }
  1706.